package hua.test;

import com.ibm.mq.MQC;
import com.ibm.mq.MQEnvironment;
import com.ibm.mq.MQException;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;

public class GetDepth {
	@SuppressWarnings({ "unchecked", "deprecation" })
	public static void main(String[] args) throws MQException {
		String hostName = "192.168.17.183";
		String channel = "SYSTEM.ADMIN.SVRCONN";
		String qManager = "QM_CRM_TEST";
		String qName = "QU_FOSS_ORDER_001_IN";
		int port = 1414;
		String userID = "mqm";
		String password = "mqm";

		/* 设置MQEnvironment 属性以便客户机连接 */
		MQEnvironment.hostname = hostName;
		MQEnvironment.channel = channel;
		// MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_WEBSPHERE
		// MQ);
		MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,
				MQC.TRANSPORT_MQSERIES_CLIENT);
		MQEnvironment.port = port;
		MQEnvironment.userID = userID;
		MQEnvironment.password = password;

		MQQueueManager qMgr = new MQQueueManager(qManager);
		int openOptions = MQC.MQOO_INPUT_AS_Q_DEF|MQC.MQOO_INQUIRE|MQC.MQOO_FAIL_IF_QUIESCING;
		MQQueue localQ = qMgr.accessQueue(qName, openOptions);
		int depth = localQ.getCurrentDepth();
		System.out.println(depth);
	}
}
